# 努力学习
# 比肩漆时祺和周期许
# import requests
# resp=requests.get(url="http://www.baidu.com")
# print(resp.test)
#
# resp2=requests.post(url="https://hmshop-test.itheima.net/index.php?m=Home&c=User&a=do_login&t=0.6120770038776953",
#                     headers={"content-type":"application/x-www-form-urlencoded"},
#                     json={"username":"18975767680","password":"aaaa","verify_code":"8888"})
# print(resp2.text)


# import json
# import requests
# resp_v=requests.get(url='验证码的url')
# cookie=resp_v.cookies
# resp=requests.post(url='登录的url',json={"username":"18975767680","password":"8888","verify_code":"8888"},cookies=cookie)
# print(resp.json())
# resp_o=requests.get(url='',cookies=cookie)

# resp2=requests.post(url="http://ihrm-test.itheima.net/api/sys/login",
#                     headers={"Content-Type":"application/json"},
#                     json={"mobile": "18975767680",
#     "password": "123456"})
# print(resp2.json())


# session=requests.Session()
# resp_v=session.get(url="http://tpshop-test,itheima,net/index,php?m=Home&c=User&a=verify")
# resp=session.post(url="http://tpshop-test,itheima.net/index.php?m=Home&c=User&a=do login",
#                   json={"username":"user","password":"123456","verify_code":"8888"})
# resp_o=session.get(url="http://tpshop-test.itheima.net/Home/Order/order list.html")
# print(resp_o.text)
# import unittest
# def add(a,b):
#     return a+b
# class TestAdd(unittest.TestCase):
#     def setUp(self):
#         print('--setUp--')
#     def tearDown(self):
#         print('--tearDown--')
#     @classmethod
#     def setUpClass(cls) -> None:
#         print('==setUpClass==')
#     @classmethod
#     def tearDownClass(cls) -> None:
#         print('==tearDownClass==')
#     def test01_add(self):
#         print('测试方法1')
#         ret=add(10,20)
#         self.assertEqual(30,ret)
#     def test02_add(self):
#         ret=add(30,20)
#         print('测试方法2')
#         self.assertEqual(50,ret)
# import unittest
# class TestIhrmLogin(unittest.TestCase):
#     def test_login_ok(self):
#         resp=requests.post(
#             url='http://ihrm-testitheima.net/api/sys/login',
#             json={"mobile":"18975767680","password":"123456"}
#         )
#         print(resp.json())
#         self.assertEqual(200,resp.status_code)
#         self.assertEqual(True,resp.json().get("sucess"))
#         self.assertEqual(10000,resp.json().get("code"))
#         self.assertEqual('操作成功',resp.json().get("message"))
#     def test_login_fal1(self):
#         resp=requests.post(
#             url='http://ihrm-testitheima.net/api/sys/login',
#             json={"mobile":"18975767681","password":"123456"}
#         )
#         print(resp.json())
#         self.assertEqual(200,resp.status_code)
#         self.assertEqual(False,resp.json().get("sucess"))
#         self.assertEqual(20001,resp.json().get("code"))
#         self.assertEqual('用户名或密码错误',resp.json().get("message"))
#     def test_login_fal2(self):
#         resp=requests.post(
#             url='http://ihrm-testitheima.net/api/sys/login',
#             json={"mobile":"18975767680","password":"123455"}
#         )
#         print(resp.json())
#         self.assertEqual(200,resp.status_code)
#         self.assertEqual(False,resp.json().get("sucess"))
#         self.assertEqual(20001,resp.json().get("code"))
#         self.assertEqual('用户名或密码错误',resp.json().get("message"))


""""""
# import direct
# import unittest
# from parameterized import parameterized
# from direct import BASE_DIR
#
# def login(username,password):
#     if username=="admin" and password=='123456':
#         return '登录成功'
#     else:
#         return '登录失败'
# def build_data():
#     with open(BASE_DIR+'/data/login_data.json','r',encoding='utf-8') as f:
#         json_data=json.load(f)
#     new_list=[]
#     for i in json_data:
#         a=tuple(i.values())
#         new_list.append(a[1:])
#     return new_list
# class TestLogin(unittest.TestCase):
#     @parameterized.expand(build_data())
#     def test_login(self,username,pwd,code,expect):
#         ret=login(username,pwd)
#         self.assertEqual(expect,ret)
#     def test_login2(self,username,pwd,code,expect):
#         resp=requests.post(url='https://hmshop-test.itheima.net/index.php/Home/user/login.html',
#                            data="username":username,)

""""""
#导包
# import pymysql
#
# #建立连接
# conn=pymysql.connect(host="192.168.143.59",port=3306,user="root",password="888888",database="cjglxt",charset="utf8")#utf8中不能加-
# #获取游标
# cursor=conn.cursor()
# #执行sql语句（查询）
# cursor.execute("select version()")
# #获取结果集
# result=cursor.fetchone()
# print(result[0])#实际返回元组类型
# #关闭游标
# cursor.close()
# #关闭连接
# conn.close()

# import pymysql
# conn=pymysql.connect(host='192.168.143.59',port=3306,user='root',password='888888',database='cjglxt',charset='utf8')
# cursor=conn.cursor()
# cursor.execute('select * from xy;')
# result=cursor.fetchone()
# cursor.rownumber=0
# result2=cursor.fetchmany(3)
# cursor.rownumber=0
# result3=cursor.fetchall()
# cursor.rownumber=2
# result4=cursor.fetchmany(2)
# print(result)
# print(result2)
# print(result3)
# print(result4)
# cursor.close()
# conn.close()

# import pymysql
# try:
#     conn=pymysql.connect(host='192.168.143.59',port=3306,user='root',password='888888',database='cjglxt',charset='utf8')
#     cursor=conn.cursor()
#     cursor.execute("insert into xy() values(111,'xx');")
#     print('影响的行数：',conn.affected_rows())
#     conn.commit()
# except Exception as e:
#     print('插入数据错误：',e)
#     conn.rollback()
# finally:
#     cursor.close()
#     conn.close()
# conn=None
# cursor=None
# import pymysql
# conn=pymysql.connect(host='192.168.143.59',port=3306,user='root',password='888888',database='cjglxt',charset='utf8')
# cursor=conn.cursor()
# cursor.execute("update xy set `name`='ddd' where id=3;")
# print('影响的行数：',conn.affected_rows())
# conn.commit()
# cursor.close()
# conn.close()

# conn=None
# cursor=None
# import pymysql
# conn=pymysql.connect(host='192.168.0.41',port=3306,user='root',password='888888',database='cjglxt',charset='utf8')
# cursor=conn.cursor()
# cursor.execute("delete from xy where name='yy';")
# print('影响的行数：',conn.affected_rows())
# conn.commit()
# cursor.close()
# conn.close()

# class DBUtil():
#     conn=None
#     @classmethod
#     def __get_conn(self):
#         if cls.conn is None:
#             cls.conn = pymysql.connect(host='192.168.0.41', port=3306, user='root', password='888888', database='cjglxt',
#                                    charset='utf8')
#         return cls.conn
#     @classmethod
#     def __close_conn(self):
#         if cls.conn is not null:
#             cls.conn.close()
#             cls.conn=None
#     @classmethod
#     def select_one(self,sql):
#         pass
#     @classmethod
#     def idu_db(self,sql):
#         pass
# if __name__ == '__main__':
#     DBUtil.select_one()
#     DBUtil.idu_db()


# import pymysql
#
# class DBUtil():
#     conn=None
#
#     #建立连接
#     @classmethod
#     def __get_conn(cls):
#         if cls.conn is None:
#             cls.conn=pymysql.connect(host='192.168.0.41',port=3306,user='root',password='888888',database='cjglxt',charset='utf8')
#         return cls.conn
#
#     #关闭连接
#     @classmethod
#     def __close_conn(cls):
#         if cls.conn is not None:
#             # cls.conn.close()
#             cls.conn=None
#     #查询语句
#     @classmethod
#     def select_one(cls,sql):
#         result = None
#         cursor = None
#         # close=None
#         try:
#             cls.conn=cls.__get_conn()
#             cursor=cls.conn.cursor()
#             cursor.execute(sql)
#             result=cursor.fetchall()
#             print(result)
#             cursor.close()
#         except Exception as e:
#             print('查询语法出错：',e)
#         finally:
#
#             cls.__close_conn()
#             return result
#     #增删改语句
#     @classmethod
#     def uid_db(cls,sql):
#         cursor=None
#         try:
#             cls.conn=cls.__get_conn()
#             curosr=cls.conn.cursor()
#             curosr.execute(sql)
#             print('影响的行数：',cls.conn.affected_rows())
#             cls.conn.commit()
#         except Exception as e:
#             cls.conn.rollback()
#             print('增删改语句出错：',e)
#         finally:
#             curosr.close()
#             cls.conn.close()
# if __name__ == '__main__':
#     DBUtil.select_one('select * from xy;')
#     DBUtil.uid_db("update xy set `name`='ddd' where id=111;")

# from direct import BASE_DIR
# from htmltestreport import HTMLTestReport
# from parameterized import parameterized
# import unittest
# import json
#
# def login(username,password):
#     if username=='18975767680' and password=='888888':
#         return '登录成功'
#     else:
#         return '登录失败'
# def build_data():
#     with open(BASE_DIR+'/data/login_data.json','r',encoding='utf-8') as f:
#         json_data=json.load(f)
#     new_list=[]
#     for i in json_data:
#         a=tuple(i.values())
#         new_list.append(a)
#     return new_list
# class TestLogin(unittest.TestCase):
#     @parameterized.expand(build_data())
#     def test_login(self,username,password,expect,code):
#         set=login(username,password)
#         self.assertEqual(expect,set)

# class TestIhrmLogin(unittest.TestCase):
#     def test_login_ok(self):
#         resp=requests.post(
#             url='http://ihrm-testitheima.net/api/sys/login',
#             json={"mobile":"18975767680","password":"123456"}
#         )
#         print(resp.json())
#         self.assertEqual(200,resp.status_code)
#         self.assertEqual(True,resp.json().get("sucess"))
#         self.assertEqual(10000,resp.json().get("code"))
#         self.assertEqual('操作成功',resp.json().get("message"))

# session=requests.Session()
# resp_v=session.get(url="http://tpshop-test,itheima,net/index,php?m=Home&c=User&a=verify")
# resp=session.post(url="http://tpshop-test,itheima.net/index.php?m=Home&c=User&a=do login",
#                   json={"username":"user","password":"123456","verify_code":"8888"})

# class TpshopLoginApi():
#     #发送验证码请求
#     @classmethod
#     def get_verify(cls,session):
#         session.get(url="http://tpshop-test,itheima,net/index,php?m=Home&c=User&a=verify")
#     #发送登录请求
#     @classmethod
#     def login(cls,session,login_data):
#         resp=session.post(url="http://tpshop-test,itheima.net/index.php?m=Home&c=User&a=do login",
#                 json=login_data)
#         return  resp
# import requests
#
#
# class TpshopLoginApi():
#     # session=requests.Session()
# #发送验证码请求
#     @classmethod
#     def send_yzm(self,session):
#         session.get(url='xxx')
#     # 发送登录请求
#     @classmethod
#     def send_login(self,session,data):
#         session.post(utl='xxx',data=data)

from common import token_data

tok=token_data.token_data_1()










# def add(a,b):
#     return a+b
